package com.example.demo;

import com.example.demo.mapper.UserMapper;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Profile;

/**
 * Spring Boot启动类
 */
@SpringBootApplication
public class DemoApplication {

    public static void main(String[] args) {
        // JDK8兼容启动配置
        System.setProperty("jdk.tls.client.protocols", "TLSv1.2");
        SpringApplication.run(DemoApplication.class, args);
    }

    /**
     * 初始化数据（JDK8兼容方式）
     */
    @Bean
    @Profile("dev")
    public CommandLineRunner dataInitRunner(UserMapper userMapper) {
        return args -> {
            System.out.println("MyBatis-Flex Demo Application Started Successfully!");
            System.out.println("API Base URL: http://localhost:8080/api");
            System.out.println("Sample Endpoints:");
            System.out.println("  GET  /api/users - 获取用户列表");
            System.out.println("  POST /api/users - 创建用户");
            System.out.println("  GET  /api/users/with-balance - 获取用户及余额");
        };
    }
}